package com.stream;

import com.alibaba.fastjson.JSON;
import com.threadLocal的使用案例.UserInfoUtils;
import com.线程案例.threadLocal.User11;

import java.util.ArrayList;
import java.util.List;
import java.util.Optional;

/**
 * @author: LCG
 * @date: 2022-10-18 13:03:05 optional的测试使用
 * @description:
 **/
public class TestOptionall {
    public static void main(String[] args) {
        User11 u1 = new User11();
        u1.setUserName("qqq");
        User11 u2 = new User11();
        u2.setUserName("qqq2");
        User11 u3 = new User11();
        u3.setUserName("qqq");
        User11 u4 = new User11();
        u4.setUserName("qqq4");
        User11 u5 = new User11();
        u5.setUserName("qqq");

        List<User11> user11List=new ArrayList<User11>();
        user11List.add(u1);
        user11List.add(u2);
        user11List.add(u3);
        user11List.add(u4);
        user11List.add(u5);

        BanJi banJi=new BanJi();
        banJi.setClassName("一年级一班");
        List<BanJi> banjiList=new ArrayList<BanJi>();
        banjiList.add(banJi);

        List<User11> user12List=null;


        Optional.ofNullable(user11List).flatMap(x->{
            return Optional.ofNullable(user12List);
        }).ifPresent((x)->{
            System.out.println("------------------");
            for (User11 user11 : x) {
                System.out.println(JSON.toJSONString(user11));
            }
        });


    }
}
